 #include <sys/types.h>          /* See NOTES */
       #include <sys/socket.h>
 #include <arpa/inet.h>
  #include <stdio.h>
   #include <netinet/in.h>

#include "lianjie.h"

int lianjie(char *id,char *dk)
{
    int sockfd=socket(AF_INET, SOCK_STREAM, 0);
    if(sockfd==-1){
        perror("socket");
        return -1;
    }
     struct sockaddr_in addr;
     addr.sin_family = AF_INET;
      addr.sin_port = htons(atoi(dk));
     inet_aton(id, &addr.sin_addr);

    if(connect(sockfd,(struct sockaddr *)&addr, sizeof(struct sockaddr_in))==-1){
        perror("connect");
        return -1;
    }else{
        printf("登陆成功！\n");
    }
    return sockfd;
}
